<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<HTML>
	<HEAD>
		<TITLE>ZTREE DEMO - Async</TITLE>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<link rel="stylesheet"
			href="${pageContext.request.contextPath}/css/zTreeStyle/zTreeStyle.css"
			type="text/css">
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.7.2.js"></script>
		<script type="text/javascript"src="${pageContext.request.contextPath}/js/jquery.ztree.core-3.2.js"></script>
		<SCRIPT type="text/javascript">
		function isSessionTimeOut() {
			$.ajax({
		   		type: "POST",
		   		url: "${pageContext.request.contextPath}/admin/isLogin",
		   		dataType: "json",
		   		success: function(json){
	     				if(json.login == 0) {
	     					alert('登录超时，请重新登录！');
	     					top.location.href = "${pageContext.request.contextPath}/admin/login";
	     				}
	   				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {
	   					alert("操作时发生了错误，请重试");
					},
				});
		}
		function zTreeOnExpand(event, treeId, treeNode) {
			isSessionTimeOut();
		};
		function zTreeOnClick(event, treeId, treeNode) {
  			isSessionTimeOut();
		};
		var setting = {
			async: {
				enable: true,
				contentType : "application/x-www-form-urlencoded",
				type : "post",
				dataType: "json",
				url:"${pageContext.request.contextPath}/admin/menu/leftMenuList",
				autoParam:["id"]
			},
			data: {
					simpleData: {
						enable: true,
						idKey: "id",
						pIdKey: "parentId"
					}
				},
			callback: {
					onExpand: zTreeOnExpand,
					onClick: zTreeOnClick
				}
		};

		$(document).ready(function(){
			$.fn.zTree.init($("#deptTree"), setting);
		});
	</SCRIPT>
	</HEAD>

	<BODY>
		<div class="content_wrap">
			<div class="zTreeDemoBackground">
				<ul id="deptTree" class="ztree"></ul>
			</div>
		</div>
	</BODY>
</HTML>